package cn.edu.ujn.park.service;

import cn.edu.ujn.park.dao.Equipment;
import cn.edu.ujn.park.dao.FeedBack;
import cn.edu.ujn.park.dao.FeedBackMapper;
import cn.edu.ujn.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedBackServiceImpl implements IFeedBackService {
    @Autowired
    private FeedBackMapper feedBackMapper;

    @Override
    public int insert(FeedBack row) {
        return feedBackMapper.insert(row);
    }

    @Override
    public List<FeedBack> selectByUserId(Integer userId) {
        return feedBackMapper.selectByUserId(userId);
    }

    @Override
    public List<FeedBack> selectAll() {
        return feedBackMapper.selectAll();
    }

    @Override
    public FeedBack selectByPrimaryKey(Integer feedBackId) {
        return feedBackMapper.selectByPrimaryKey(feedBackId);
    }

    @Override
    public int updateByPrimaryKey(FeedBack row) {
        return feedBackMapper.updateByPrimaryKey(row);
    }

    @Override
    public int deleteByPrimaryKey(Integer feedBackId) {
        return feedBackMapper.deleteByPrimaryKey(feedBackId);
    }

    @Override
    public Page<FeedBack> selectAll1(FeedBack feedBack) {
        Page<FeedBack> page = new Page<>();
        List<FeedBack> feedBacks = feedBackMapper.selectAll1(feedBack);
        page.setPage(feedBack.getStart());
        page.setRows(feedBacks);
        page.setSize(feedBack.getRows());
        page.setTotal(feedBackMapper.selectCount());
        return page;
    }

    @Override
    public Page<FeedBack> selectByUserId1(FeedBack feedBack) {
        Page<FeedBack> page = new Page<>();
        List<FeedBack> feedBacks = feedBackMapper.selectByUserId1(feedBack);
        page.setPage(feedBack.getStart());
        page.setRows(feedBacks);
        page.setSize(feedBack.getRows());
        page.setTotal(feedBackMapper.selectCountByUserId(feedBack.getUserId()));
        return page;
    }
}
